﻿using RabbitMQ.Client;
using System;
using System.Text;

namespace RabbitMQ.Demo.Send
{
    public class Send
    {
        private static void Main(string[] args)
        {
            var factory = new ConnectionFactory() { HostName = "localhost" };
            using (var connection = factory.CreateConnection())
            {
                using (var channl = connection.CreateModel())
                {
                    channl.QueueDeclare("hello", durable: false, exclusive: false, autoDelete: false, arguments: null);
                    var message = "hello word ! rabbitMQ!";
                    var body = Encoding.UTF8.GetBytes(message);

                    channl.BasicPublish(exchange: "", routingKey: "hello", basicProperties: null, body: body);
                    Console.WriteLine(" [x] Sent {0}", message);
                }
            }
            Console.WriteLine(" Press [enter] to exit.");
            Console.ReadLine();
        }
    }
}